package com.sproutcat.sample;

import java.util.concurrent.*;

public class MyCallable implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        Thread.sleep(1000);
        return 100;
    }


    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable mc = new MyCallable();
        FutureTask<Integer> ft = new FutureTask<>(mc);
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        executorService.execute(ft);
        System.out.println(ft.get());
        executorService.shutdown();
    }
}
